<?php
	include ('../../inc/global.php');
	include('productsfunction.php');
	$root = 'http://cs.newpaltz.edu/~N02223133/2011/';
if (isset($_GET['id']) && (int)$_GET['id'] > 0) {
   $id = (int)$_GET['id'];
} else {
   header('Location:list.php');
} 

$sql = "SELECT *
        FROM Products
        WHERE id = $id";
		  $conn = getConnection();
		  $result = $conn->query($sql);
		 $rs = $result->fetch_assoc();
        $conn->close();


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<form method="post" enctype="multipart/form-data" name="frmAddProduct" id="frmAddProduct">
 <h2 style="text-align:center">Edit Product</h2>
 <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="entryTable">
  <tr> 
   <td width="150" class="label">Product Name</td>
   <td class="content"> <input name="txtName" type="text" class="box" id="txtName" value="<?=$rs['product_name']?>" size="50" maxlength="100"></td>
  </tr>
  <tr> 
   <td width="150" class="label">Description</td>
   <td class="content"> <textarea name="mtxDescription" cols="70" rows="10" class="box" id="mtxDescription"><?=$rs['product_desc']?></textarea></td>
  </tr>
  <tr> 
   <td width="150" class="label">Price</td>
   <td class="content"><input name="txtPrice" type="text" class="box" id="txtPrice" value="<?=$rs['price']?>" size="10" maxlength="7"> </td>
  </tr>
  <tr> 
   <td width="150" class="label">Qty In Stock</td>
   <td class="content"><input name="txtQty" type="text" class="box" id="txtQty" value="<?=$rs['inventory']?>" size="10" maxlength="10"> </td>
  </tr>
  <tr> 
   <td width="150" class="label">Image</td>
   <td class="content"> <input name="fleImage" type="file" id="fleImage" class="box">
    <br>
    <img src="<? echo $root?>/images/products/<?=$rs['product_pic']?>"> &nbsp;&nbsp;
    <a href="javascript:deleteImage(<?php echo $id; ?>);">Delete 
    Image</a> 
    </td>
  </tr>
 </table>
 <p align="center"> 
  <input name="btnModifyProduct" type="button" id="btnModifyProduct" value="Modify Product" onClick="checkAddProductForm();" class="box">
  &nbsp;&nbsp;<input name="btnCancel" type="button" id="btnCancel" value="Cancel" onClick="window.location.href='list.php';" class="box">  
 </p>
</form>
<body>
</body>
</html>